package com.zhongshan.ga.mobile.resource;

import java.io.IOException;

import org.restlet.ext.json.JsonRepresentation;
import org.restlet.representation.Representation;
import org.restlet.representation.StringRepresentation;
import org.restlet.resource.Get;
import org.restlet.resource.Post;
import org.restlet.resource.ServerResource;

import com.google.gson.JsonObject;
import com.zhongshan.ga.logger.GenerateLog;
import com.zhongshan.ga.mobile.logic.GetPostcardInfoListLogic;

/**
 * 
 * 获取明信片接口
 * @author kakaxi
 *
 */
public class GetPostcardInfoListResource extends ServerResource {
	
	@Get
	public Representation getPostcardInfoList(Representation entity)throws IOException {
		GenerateLog.outDebug("调用了获得明信片信息的方法");
		entity = postPostcardInfoList(entity);
		return entity;
	}
	
	@Post
	public Representation postPostcardInfoList(Representation entity)throws IOException {
		if (entity == null) {
			return new StringRepresentation("访问有误");
		}
		
		GenerateLog.outDebug("请求获得明信片信息的post方法");
		GetPostcardInfoListLogic logic = new GetPostcardInfoListLogic();
		JsonObject resultJson = logic.getPostcardInfoList(entity);
		return new JsonRepresentation(resultJson.toString());
	}
	
}
